package com.sg.service.base.app.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.dto.base.app.req.*;
import com.sg.entity.OmsTask;
import com.sg.service.base.app.MOmsTaskService;
import com.wicket.okrapp.common.dto.FieldInfo;
import com.wicket.okrapp.common.exception.BizException;
import com.wicket.okrapp.dal.mapper.mbg.OmsTaskMapper;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ：
 * @version 1.0
 * @since 2022/1/19 15:39
 */
@Service
public class MOmsTaskServiceImpl
        extends ServiceImpl<OmsTaskMapper, OmsTask>
        implements MOmsTaskService {

    @Autowired
    OmsTaskMapper omsTaskMapper;

    /**
     * 3-7-01修改任务[2706]
     * gen by moon at 10/15/2022, 10:04:45 PM
     */
    @Trace(operationName = "3-7-01修改任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateTask(OmsTask omsTask) {
        omsTask.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTask.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        return super.updateById(omsTask);
    }

    /**
     * 3-7-01批量查任务列表[2566]
     * gen by moon at 10/15/2022, 10:04:45 PM
     */
    @Trace(operationName = "3-7-01批量查任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryTask(BatchQueryTaskReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getReportingTaskList() == null || reqDto.getReportingTaskList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("task_id", reqDto.getReportingTaskList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询任务详情[2522]
     * gen by moon at 3/30/2023, 12:39:16 PM
     */
    @Trace(operationName = "3-7-01查询任务详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTask queryTaskDetail(QueryTaskDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTask> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTask retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询任务列表[2519]
     * gen by moon at 3/3/2023, 11:35:27 PM
     */
    @Trace(operationName = "3-7-01查询任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryTaskList(QueryTaskListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("task_code");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01新增任务[2421]
     * gen by moon at 10/15/2022, 10:04:41 PM
     */
    @Trace(operationName = "3-7-01新增任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addTask(OmsTask omsTask) {
        omsTask.setTaskId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsTask.setTaskNumber(CommonFunctionHelper.getUid());//AUTO_GENERATE
        omsTask.setIsArchive("FALSE");
        omsTask.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTask.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTask.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTask.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTask.setIsValid("FALSE");
        omsTask.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsTask.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsTask)) {
            return omsTask.getTaskId();
        } else {
            return "-1";
        }

    }

    /**
     * 3-7-01批量查询汇报任务by内容表主键ID[3912]
     * gen by moon at 9/25/2023, 6:41:51 PM
     */
    @Trace(operationName = "3-7-01批量查询汇报任务by内容表主键ID")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryReportingTask(BatchQueryReportingTaskReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            if (reqDto.getSameLevelEvaObjTargetCycleList() == null || reqDto.getSameLevelEvaObjTargetCycleList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("entity_id", reqDto.getSameLevelEvaObjTargetCycleList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01删除任务[4212]
     * gen by moon at 10/15/2022, 10:04:47 PM
     */
    @Trace(operationName = "3-7-01删除任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteTask(String taskId) {

        return super.removeById(taskId);
    }

    /**
     * M3-7-01新增汇报任务[4351]
     * gen by moon at 10/15/2022, 10:04:47 PM
     */
    @Trace(operationName = "M3-7-01新增汇报任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addReportTask(OmsTask omsTask) {
        omsTask.setTaskId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsTask.setTaskNumber(CommonFunctionHelper.getUid());//AUTO_GENERATE
        omsTask.setIsArchive("FALSE");
        omsTask.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTask.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTask.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        omsTask.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTask.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTask.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        omsTask.setIsValid("FALSE");
        omsTask.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsTask.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsTask)) {
            return omsTask.getTaskId();
        } else {
            return "-1";
        }

    }

    /**
     * M3-7-01查询汇报任务相关详情[4359]
     * gen by moon at 3/30/2023, 12:39:16 PM
     */
    @Trace(operationName = "M3-7-01查询汇报任务相关详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTask queryReportTaskRelatedDataDetail(OmsTask omsTask) {

        try {

            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(omsTask);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTask> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTask retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * M3-07-01一键删除汇报任务验证数据[4426]
     * gen by moon at 10/15/2022, 10:04:49 PM
     */
    @Trace(operationName = "M3-07-01一键删除汇报任务验证数据")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean autoDeleteReportTask(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * M3-07-01查询汇报任务系统测试列表[4458]
     * gen by moon at 9/7/2024, 1:17:38 PM
     */
    @Trace(operationName = "M3-07-01查询汇报任务系统测试列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryReportTaskList(QueryReportTaskListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询汇报任务列表[4805]
     * gen by moon at 3/3/2023, 6:35:25 PM
     */
    @Trace(operationName = "3-7-01查询汇报任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryReportingTaskList(QueryReportingTaskListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量删汇报任务[4806]
     * gen by moon at 10/15/2022, 10:04:52 PM
     */
    @Trace(operationName = "3-7-01批量删汇报任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchDeleteReportingTask(List<String> reqDto) {

        if (reqDto == null || reqDto.size() == 0) {
            return false;
        }

        return super.removeByIds(reqDto);
    }

    /**
     * 3-7-01批量查询任务列表By父内容表主键ID[5552]
     * gen by moon at 12/30/2022, 6:32:47 PM
     */
    @Trace(operationName = "3-7-01批量查询任务列表By父内容表主键ID")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryTaskListByIds(BatchQueryTaskListByIdsReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            reqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
            if (reqDto.getReportingTaskList() == null || reqDto.getReportingTaskList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("parent_entity_id", reqDto.getReportingTaskList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量查询任务列表by虚拟组织ID[7316]
     * gen by moon at 5/17/2024, 11:08:45 PM
     */
    @Trace(operationName = "3-7-01批量查询任务列表by虚拟组织ID")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryReportingTaskListByVirtualOrgListByIds(BatchQueryReportingTaskListByVirtualOrgListByIdsReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getVirtualOrgList() == null || reqDto.getVirtualOrgList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("virtual_org_id", reqDto.getVirtualOrgList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("plan_start_time");
            queryWrapper.orderByAsc("tree_order_number");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * M3-07-01修改汇报任务[7335]
     * gen by moon at 8/2/2023, 12:25:14 PM
     */
    @Trace(operationName = "M3-07-01修改汇报任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateModifyReportTask(OmsTask omsTask) {

        return super.updateById(omsTask);
    }

    /**
     * 3-7-01修改汇报任务[7508]
     * gen by moon at 10/8/2023, 8:46:40 PM
     */
    @Trace(operationName = "3-7-01修改汇报任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateReportingTask(OmsTask omsTask) {

        return super.updateById(omsTask);
    }

    /**
     * 3-7-01批量改汇报任务[7641]
     * gen by moon at 11/1/2023, 6:21:11 PM
     */
    @Trace(operationName = "3-7-01批量改汇报任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean batchUpdateReportingTask(List<OmsTask> omsTask) {

        if (omsTask == null || omsTask.size() == 0) {
            return false;
        }
        return super.saveOrUpdateBatch(omsTask);

    }

    /**
     * 3-7-02查询独立任务列表[7748]
     * gen by moon at 12/7/2023, 6:14:44 PM
     */
    @Trace(operationName = "3-7-02查询独立任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryIndependentTaskList(QueryIndependentTaskListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            // TODO: 2023/11/15 手写代码
            if (reqDto.getPlanStartTime() != null && reqDto.getPlanEndTime() != null) {
                queryWrapper.ge("plan_start_time", reqDto.getPlanStartTime());
                queryWrapper.le("plan_end_time", reqDto.getPlanEndTime());
                reqDto.setPlanStartTime(null);
                reqDto.setPlanEndTime(null);
            }

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01新增独立任务（或子任务）[7754]
     * gen by moon at 1/2/2024, 12:37:02 PM
     */
    @Trace(operationName = "3-7-01新增独立任务（或子任务）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addIndependentTask(OmsTask omsTask) {
        omsTask.setTaskId(CommonFunctionHelper.getUid());//DISTRIBUTED_ID
        omsTask.setTaskCode("T" + CommonFunctionHelper.getUid());//AUTO_GENERATE
        omsTask.setBizAppCode("LIGHT_OA_APP");//CUSTOM_CONVENTION
        omsTask.setBizSceneCode("WORK_TASK");//CUSTOM_CONVENTION
        omsTask.setPercentageProgress(Double.valueOf("0"));//CUSTOM_CONVENTION
        omsTask.setIsAutoReport("FALSE");
        omsTask.setIsComplete("FALSE");
        omsTask.setIsOverdue("FALSE");
        omsTask.setIsRegularTask("FALSE");
        omsTask.setOrderNumber(Long.valueOf(1));//CUSTOM_CONVENTION
        omsTask.setIsArchive("FALSE");
        omsTask.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        omsTask.setCreateInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTask.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        omsTask.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        omsTask.setCreateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTask.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        omsTask.setIsValid("FALSE");
        omsTask.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID
        omsTask.setAppId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecAppId());//CURRENT_APPID
        if (super.save(omsTask)) {
            return omsTask.getTaskId();
        } else {
            return "-1";
        }

    }

    /**
     * 3-7-02批量查询独立任务[7762]
     * gen by moon at 12/16/2023, 8:27:37 PM
     */
    @Trace(operationName = "3-7-02批量查询独立任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryIndependentTask(BatchQueryIndependentTaskReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getIndependentTaskList() == null || reqDto.getIndependentTaskList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("task_id", reqDto.getIndependentTaskList());

            // TODO: 2023/11/15 手写代码
            if (reqDto.getPlanStartTime() != null && reqDto.getPlanEndTime() != null) {
                queryWrapper.le("plan_start_time", reqDto.getPlanStartTime());
                queryWrapper.ge("plan_end_time", reqDto.getPlanEndTime());
                reqDto.setPlanStartTime(null);
                reqDto.setPlanEndTime(null);
            }
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01修改独立任务或子任务[7780]
     * gen by moon at 11/8/2023, 3:43:06 PM
     */
    @Trace(operationName = "3-7-01修改独立任务或子任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateIndependentTask(OmsTask omsTask) {
        omsTask.setOperationInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//CURRENT_INDUCTIONID
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTask.setReleaseInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//RELEASED_CURRENT_INDUCTIONID
        }
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsTask.setArchiveInductionId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecInductionRecordId());//ARCHIVE_CURRENT_INDUCTIONID
        }
        omsTask.setOperateTime(CommonFunctionHelper.getCurrentTime());//SYSTEM_CURRENT_TIME
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("CURRENTLY_VALID")) {
            omsTask.setReleaseTime(CommonFunctionHelper.getCurrentTime());//RELEASE_SYSTEM_CURRENT_TIME
        }
        if (omsTask != null && omsTask.getSubjectLifeCycle() != null && omsTask.getSubjectLifeCycle().equals("ARCHIVING")) {
            omsTask.setArchiveTime(CommonFunctionHelper.getCurrentTime());//HISTORICAL_ARCHIVING
        }
        return super.updateById(omsTask);
    }

    /**
     * 3-7-01查询独立任务详情[7792]
     * gen by moon at 11/8/2023, 3:43:10 PM
     */
    @Trace(operationName = "3-7-01查询独立任务详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OmsTask queryIndependentTaskDetail(QueryIndependentTaskDetailReq reqDto) {

        try {
            reqDto.setIsValid("FALSE");
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, new ArrayList<>());
            queryWrapper.orderByDesc("create_time");
            List<OmsTask> retList = super.list(queryWrapper);
            if (retList != null && retList.size() > 0) {
                OmsTask retData = retList.get(0);

                return retData;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01删除独立任务[7795]
     * gen by moon at 11/8/2023, 3:43:12 PM
     */
    @Trace(operationName = "3-7-01删除独立任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteIndependentTask(String taskId) {

        return super.removeById(taskId);
    }

    /**
     * 3-7-02查询工作任务列表[8168]
     * gen by moon at 1/6/2024, 11:28:20 PM
     */
    @Trace(operationName = "3-7-02查询工作任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryWorkTaskList(QueryWorkTaskListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

            if (reqDto.getPlanStartTime() != null) {
                queryWrapper.ge("plan_start_time", reqDto.getPlanStartTime());
                reqDto.setPlanStartTime(null);
            }

            if (reqDto.getAlignmentTime() != null) {
                queryWrapper.le("alignment_time", reqDto.getAlignmentTime());
                reqDto.setAlignmentTime(null);
            }

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = new ArrayList<>();
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-02查询自动汇报任务列表[7749]
     * gen by moon at 1/6/2024, 11:28:17 PM
     */
    @Trace(operationName = "3-7-02查询自动汇报任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryAutomatedReportingTasksList(QueryAutomatedReportingTasksListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            reqDto.setIsValid("FALSE");
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByAsc("plan_start_time");
            queryWrapper.orderByDesc("tree_order_number");
            queryWrapper.orderByDesc("operate_time");

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量查询工作任务[8875]
     * gen by moon at 3/29/2024, 8:31:58 PM
     */
    @Trace(operationName = "3-7-01批量查询工作任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryWorkTask(BatchQueryWorkTaskReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            // TODO: 2024/8/6
            if (reqDto.getCreateTime() != null && reqDto.getPlanStartTime() != null) {
                queryWrapper.ge("create_time", reqDto.getCreateTime());
                queryWrapper.le("plan_start_time", reqDto.getPlanStartTime());
                reqDto.setCreateTime(null);
                reqDto.setPlanStartTime(null);
            }

            if (reqDto.getTaskDataList() == null || reqDto.getTaskDataList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("task_id", reqDto.getTaskDataList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量查询大屏工作任务[8883]
     * gen by moon at 3/29/2024, 8:32:02 PM
     */
    @Trace(operationName = "3-7-01批量查询大屏工作任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryDashboardWorkTask(BatchQueryDashboardWorkTaskReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getWorkTaskList() == null || reqDto.getWorkTaskList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("task_id", reqDto.getWorkTaskList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询大屏任务列表[8887]
     * gen by moon at 3/29/2024, 8:32:05 PM
     */
    @Trace(operationName = "3-7-01查询大屏任务列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryTaskDataList(QueryTaskDataListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

// TODO: 2024/8/6
            if (reqDto.getCreateTime() != null && reqDto.getPlanStartTime() != null) {
                queryWrapper.ge("create_time", reqDto.getCreateTime());
                queryWrapper.le("plan_start_time", reqDto.getPlanStartTime());
                reqDto.setCreateTime(null);
                reqDto.setPlanStartTime(null);
            }


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量查询汇报任务By归属对象ID[8904]
     * gen by moon at 3/29/2024, 8:32:09 PM
     */
    @Trace(operationName = "3-7-01批量查询汇报任务By归属对象ID")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryReportTask(BatchQueryReportTaskReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");
            if (reqDto.getReportingTaskList() == null || reqDto.getReportingTaskList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("parent_entity_id", reqDto.getReportingTaskList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量查询任务进度排行[8999]
     * gen by moon at 4/1/2024, 12:12:07 AM
     */
    @Trace(operationName = "3-7-01批量查询任务进度排行")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryTaskProgressRank(BatchQueryTaskProgressRankReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            if (reqDto.getTaskDataList() == null || reqDto.getTaskDataList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("task_id", reqDto.getTaskDataList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("percentage_progress");
            queryWrapper.orderByDesc("total_length");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01批量查询任务逾期排行[9002]
     * gen by moon at 4/1/2024, 12:12:08 AM
     */
    @Trace(operationName = "3-7-01批量查询任务逾期排行")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryTaskExpiedRank(BatchQueryTaskExpiedRankReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            if (reqDto.getTaskDataList() == null || reqDto.getTaskDataList().isEmpty()) {
                return new ArrayList<>();
            }
            queryWrapper.in("task_id", reqDto.getTaskDataList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("deflection_time");
            queryWrapper.orderByAsc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询任务逾期排行列表[9076]
     * gen by moon at 4/2/2024, 6:12:58 PM
     */
    @Trace(operationName = "3-7-01查询任务逾期排行列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryTaskExpiedRankList(QueryTaskExpiedRankListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("deflection_time");
            queryWrapper.orderByAsc("create_time");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-4-07查询任务进度排行列表(公共)[9078]
     * gen by moon at 4/2/2024, 6:12:59 PM
     */
    @Trace(operationName = "3-4-07查询任务进度排行列表(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryTaskProgressRankListCom(QueryTaskProgressRankListComReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();


            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);
            queryWrapper.orderByDesc("percentage_progress");
            queryWrapper.orderByDesc("total_length");
            queryWrapper.orderByDesc("operate_time");
            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询时间统计任务列表(公共)[10074]
     * gen by moon at 8/8/2024, 9:44:06 AM
     */
    @Trace(operationName = "3-7-01查询时间统计任务列表(公共)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryTimeStatisticsTasksListCom(QueryTimeStatisticsTasksListComReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            // TODO: 2024/8/8  
            if (reqDto.getPlanStartTime() != null && reqDto.getPlanEndTime() != null) {
                queryWrapper.nested(wrapper ->
                        wrapper.le("plan_start_time", reqDto.getPlanStartTime()).ge("plan_end_time", reqDto.getPlanStartTime())
                                .or()
                                .le("plan_start_time", reqDto.getPlanEndTime()).ge("plan_end_time", reqDto.getPlanEndTime())
                                .or()
                                .ge("plan_start_time", reqDto.getPlanStartTime()).le("plan_end_time", reqDto.getPlanEndTime())
                );
                reqDto.setPlanStartTime(null);
                reqDto.setPlanEndTime(null);
            }
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-09批量查询时间统计任务[10076]
     * gen by moon at 8/8/2024, 9:44:10 AM
     */
    @Trace(operationName = "3-7-09批量查询时间统计任务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> batchQueryTimeStatisticsTasks(BatchQueryTimeStatisticsTasksReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();

            if (reqDto.getTaskDataList() == null || reqDto.getTaskDataList().isEmpty()) {
                return new ArrayList<>();
            }
            // TODO: 2024/8/8  
            if (reqDto.getPlanStartTime() != null && reqDto.getPlanEndTime() != null) {
                queryWrapper.nested(wrapper ->
                        wrapper.le("plan_start_time", reqDto.getPlanStartTime()).ge("plan_end_time", reqDto.getPlanStartTime())
                                .or()
                                .le("plan_start_time", reqDto.getPlanEndTime()).ge("plan_end_time", reqDto.getPlanEndTime())
                                .or()
                                .ge("plan_start_time", reqDto.getPlanStartTime()).le("plan_end_time", reqDto.getPlanEndTime())
                );
                reqDto.setPlanStartTime(null);
                reqDto.setPlanEndTime(null);
            }
            queryWrapper.in("task_id", reqDto.getTaskDataList());
            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

    /**
     * 3-7-01查询工作任务列表by时间范围列表[10204]
     * gen by moon at 8/31/2024, 8:22:08 PM
     */
    @Trace(operationName = "3-7-01查询工作任务列表by时间范围列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<OmsTask> queryWrokTaskByTimeRangeList(QueryWrokTaskByTimeRangeListReq reqDto) {

        try {
            QueryWrapper<OmsTask> queryWrapper = new QueryWrapper<>();
            reqDto.setIsValid("FALSE");

// TODO: 2024/8/6
            if (reqDto.getPlanStartTime() != null && reqDto.getPlanEndTime() != null) {
                queryWrapper.ge("plan_start_time", reqDto.getPlanStartTime());
                queryWrapper.le("plan_end_time", reqDto.getPlanEndTime());
                reqDto.setPlanStartTime(null);
                reqDto.setPlanEndTime(null);
            }

            Map<String, Object> fieldInfoMap = null;
            fieldInfoMap = CommonFunctionHelper.objectToMapForLamBda(reqDto);
            List<FieldInfo> compareList = CommonFunctionHelper.getRangeField(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperCompare(queryWrapper, compareList, fieldInfoMap);
            List<FieldInfo> likeList = CommonFunctionHelper.getLikeFiled(OmsTask.class);
            CommonFunctionHelper.buildQueryWrapperLike(queryWrapper, likeList, fieldInfoMap);
            likeList.addAll(compareList);
            CommonFunctionHelper.buildQueryWrapperEq(queryWrapper, fieldInfoMap, likeList);
            List<FieldInfo> orderList = CommonFunctionHelper.getOrderList(OmsTask.class);
            //CommonFunctionHelper.buildQueryWrapperOrder(queryWrapper, orderList);

            return ((List<OmsTask>) super.list(queryWrapper));
        } catch (Exception e) {
            e.printStackTrace();
            throw new BizException("-1", e, false);
        }
    }

}


